// 泛型 generics
function dump<T>(arg: T): T {
  return arg
}

let str = dump<string>('string.....')
let bool = dump<boolean>(true)
let num = dump(21) //它会自动能推断的类型

// extends
// T继承含有length属性的类型 
// function getLength<T extends string | any[]>(arg:T):number{
function getLength<T extends { length: number }>(arg: T): number {
  return arg.length
}
console.log(getLength('coderzrf'));
console.log(getLength([1, 2, 3]));

